package org.dinqy.impl;

import org.dinqy.ClauseBeanFactory;
import org.dinqy.syntax.AscDesc;

/**
 * @author armandino (at) gmail.com
 */
public class AscDescNode<T> extends LimitOffsetNode<T> implements AscDesc<T> {

    AscDescNode(ClauseNode<T> parent) {
        super(parent);
    }

    @Override
    public AscDesc<T> asc(String fieldName) {
        setClauseBean(ClauseBeanFactory.asc(fieldName));
        return createSuccessor();
    }

    @Override
    public AscDesc<T> desc(String fieldName) {
        setClauseBean(ClauseBeanFactory.desc(fieldName));
        return createSuccessor();
    }

    private AscDesc<T> createSuccessor() {
        AscDescNode<T> successor = new AscDescNode<T>(this);
        setSuccessor(successor);
        return successor;
    }
}
